package com.johnny.xia.game;

import java.util.ArrayList;
import java.util.List;

public class Combination{

    public static void combiantion(int[] arrays){
        if (arrays == null || arrays.length == 0){
            return;
        }
        List<Integer> list = new ArrayList<>();
        for (int i = 1; i <= arrays.length; i++){
            combine(arrays, 0, i, list);
        }
    }

    //从字符数组中第begin个字符开始挑选number个字符加入list中  
    public static void combine(int[] arrays,int begin,int number,List<Integer> list){
        if (number == 0){
            System.out.println(list.toString());
            return;
        }
        if (begin == arrays.length){
            return;
        }
        list.add(arrays[begin]);
        combine(arrays, begin + 1, number - 1, list);
        list.remove(arrays[begin]);
        combine(arrays, begin + 1, number, list);
    }

    public static void main(String args[]){
        int chs[] = { 1, 2, 3 };
        combiantion(chs);
    }
}
